using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class EconomyTestLabel : MonoBehaviour
{
	private Text text;

	private string header;

	private void Awake()
	{
		text = GetComponent<Text>();
	}

	private IEnumerator Start()
	{
		Economy.PurchaseFinishedEvent += PuchaseFinished;
		yield return new WaitForSeconds(5f);
	}

	private void Update()
	{
		UpdateHeader(0);
		UpdateLabel();
	}

	private void UpdateHeader(int livesDelta)
	{
		header = "Lives  = " + Economy.lives;
	}

	private void UpdateLabel()
	{
		if (this.text != null)
		{
			string text = header + "\n";
			text = text + Economy.GetFormattedPriceForProduct(IAPManager.ProductType.LivesPack1) + "\n";
			text = text + Economy.GetFormattedPriceForProduct(IAPManager.ProductType.LivesPack2) + "\n";
			text = text + Economy.GetFormattedPriceForProduct(IAPManager.ProductType.LivesPack3) + "\n";
			this.text.text = text;
		}
	}

	public void PostToFB()
	{
		Debug.Log("FB available = " + Economy.isFacebookAvailable);
		Economy.Share(SocialManager.SharePlatform.Facebook, true, string.Empty);
	}

	public void PostToTwitter()
	{
		Economy.Share(SocialManager.SharePlatform.Twitter, true, string.Empty);
	}

	public void PostToOther()
	{
		Economy.Share(SocialManager.SharePlatform.Other, true, string.Empty);
	}

	public void BuyLives(int lives)
	{
		Economy.PurchaseProduct((IAPManager.ProductType)lives);
	}

	private void PuchaseFinished(bool result)
	{
		Debug.Log("purchase finished " + result);
	}

	public void ShowInterstitialAd()
	{
	}

	public void ShowRewardedAd()
	{
	}
}
